﻿using System;
using System.Linq;
using System.Windows.Forms;

namespace DuplicateRemoval
{
    public partial class DuplicateRemove : Form
    {
        public DuplicateRemove()
        {
            InitializeComponent();
        }

        private void btnRasterized_Click(object sender, EventArgs e)
        {
            if (rTB_InPut.Text=="")
            {
                lblLog.Text = "文本为空！";
                return;
            }
            if (rTB_InPut.Text.Length>20000)
            {
                lblLog.Text = "文本过长！";
                return;
            }
            rTB_OutPut.Text= rTB_InPut.Text.Replace("\n", "").Replace(" ", "").Replace("\t", "").Replace("\r", "");
            lblLog.Text = "栅格化成功";
        }

        private void btnDuplicate_Click(object sender, EventArgs e)
        {
            if (rTB_InPut.Text == "")
            {
                lblLog.Text = "文本为空！";
                return;
            }
            if (rTB_InPut.Text.Length > 20000)
            {
                lblLog.Text = "文本过长！";
                return;
            }
            rTB_OutPut.Text = string.Join("", rTB_InPut.Text.Distinct().ToArray());
            lblLog.Text = "去重成功";
        }

        private void btnCopy_Click(object sender, EventArgs e)
        {
            if (rTB_OutPut.Text == "")
            {
                lblLog.Text = "文本为空！";
                return;
            }
            Clipboard.SetText(rTB_OutPut.Text);
            lblLog.Text = "复制成功";
        }
        private void btnRasterized2Duplicate_Click(object sender, EventArgs e)
        {
            if (rTB_InPut.Text == "")
            {
                lblLog.Text = "文本为空！";
                return;
            }
            if (rTB_InPut.Text.Length > 20000)
            {
                lblLog.Text = "文本过长！";
                return;
            }
            rTB_OutPut.Text = string.Join("", (rTB_InPut.Text.Replace("\n", "").Replace(" ", "").Replace("\t", "").Replace("\r", "")).Distinct().ToArray());
            lblLog.Text = "去重成功";
        }

        private void btnClear_Click(object sender, EventArgs e)
        {
            rTB_InPut.Text = "";
            rTB_OutPut.Text = "";
            lblLog.Text = "清空成功";
        }
    }
}
